Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get cash import by date Entity Framework rewrite #155

Open
wants to merge 17 commits into
base: development
Choose a base branch
from

Conversation

adamtry
Copy link
Contributor

@adamtry adamtry commented Aug 1, 2024

Tests for this process, rewritten in Entity Framework.

Runs on the EE Docker environment (make unit_db_ee)

See sproc code: https://github.com/LBHackney-IT/HFSDatabaseObjects/blob/880959d860c087cde6f946f16834e8f5b2416c0a/stored_procedures/usp_GetCashImportByDate.sql

What the stored procedure does is:

  • Gets cash amounts by cash file
  • Gets total (sum) transactions by rent group by date
  • Returns a list of csv-like rows giving a breakdown of how much money was loaded in total and broken down by rent group

The test works the same with the original stored procedure SQL and the new entity framework code

adamtry and others added 2 commits August 1, 2024 13:31
* Add SSMiniTransaction entity

* Stub test

* Improve setup

* SSmini DB setup

* Working test case

* Pull out duplicate data gen

* Unneeded warning suppression

* Format

* Cleanup

* Check for suspense transactions

* Cleanup

* format

* Rename

* Extract var

* Remove brackets
@adamtry adamtry changed the title Test get cash import by date (#154) Migrate get cash import by date (#154) Aug 1, 2024
@adamtry adamtry changed the title Migrate get cash import by date (#154) Migrate get cash import by date Aug 8, 2024
@adamtry adamtry marked this pull request as ready for review August 8, 2024 10:39
@adamtry adamtry requested review from FaisalHackney, Duslerke and a team as code owners August 8, 2024 10:39
@adamtry adamtry changed the title Migrate get cash import by date Get cash import by date Entity Framework rewrite Aug 8, 2024
@@ -39,7 +39,7 @@ dotnet_naming_symbols.public_symbols.applicable_accessibilities = public

#Parameters should be camel case
dotnet_naming_style.camel_case_style.capitalization = camel_case
dotnet_naming_rule.local_objects_must_be_camel_case.severity = error
dotnet_naming_rule.local_objects_must_be_camel_case.severity = suggestion
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We consistently don't follow this rule, so it just gets in the way

@@ -136,3 +136,6 @@ dotnet_diagnostic.CA1001.severity = none

#Can reassign collections
dotnet_diagnostic.CA2227.severity = none

# No need to mark CLSCompliant
dotnet_diagnostic.CA1014.severity = none
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't something we've been following so this suppresses the warnings

@@ -552,95 +552,6 @@ await _classUnderTest
}
#endregion

#region Cash Import
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are redundant now because we're no longer calling this method for this report - there's nothing to mock and the new test runs directly against the Dockerised db

* with the total value of transactions for each rent group
* with summed totals across all rent groups
*/

[Fact]
public async void ShouldGetCashImportByDate()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanded this test to insert multiple records and ensure that they were being grouped and aggregated correctly

@@ -63,5 +64,31 @@ public interface IDatabaseContext
Task<List<string[]>> GetItemisedTransactionsByYearAndTransactionTypeAsync(int year, string transactionType);
Task<List<string[]>> GetHousingBenefitAcademyByYear(int year);
Task<IList<string[]>> GetReportAccountBalance(DateTime reportDate, string rentGroup);

public DbSet<BatchLog> BatchLogs { get; set; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These weren't in the interface and so didn't allow access in the tests - added these for current and future convenience

@@ -41,7 +41,7 @@ public async Task ShouldLoadHousingFilesAndReturnStepResponse()

// Assert
result.Continue.Should().BeTrue();
result.NextStepTime.Should().BeCloseTo(DateTime.Now.AddSeconds(_waitDuration));
result.NextStepTime.Should().BeCloseTo(DateTime.Now.AddSeconds(_waitDuration), 500);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was flaky on CircleCI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants